# 思和智库 - 一键启动脚本
# 同时启动前端和后端服务

Write-Host "==================================" -ForegroundColor Cyan
Write-Host "  思和智库 - 一键启动" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""

# 设置控制台编码为 UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
chcp 65001 | Out-Null

Write-Host "✓ 已设置 UTF-8 编码" -ForegroundColor Green
Write-Host ""

# 启动后端（新窗口）
Write-Host "启动后端服务..." -ForegroundColor Yellow
Start-Process powershell -ArgumentList "-NoExit", "-ExecutionPolicy", "Bypass", "-File", ".\start_backend.ps1"

# 等待2秒
Start-Sleep -Seconds 2

# 启动前端（新窗口）
Write-Host "启动前端服务..." -ForegroundColor Yellow
Start-Process powershell -ArgumentList "-NoExit", "-ExecutionPolicy", "Bypass", "-File", ".\start_frontend.ps1"

Write-Host ""
Write-Host "==================================" -ForegroundColor Green
Write-Host "  ✓ 服务启动完成！" -ForegroundColor Green
Write-Host "==================================" -ForegroundColor Green
Write-Host ""
Write-Host "访问地址：" -ForegroundColor Cyan
Write-Host "  前端: http://localhost:3300" -ForegroundColor White
Write-Host "  API: http://localhost:3301/docs" -ForegroundColor White
Write-Host ""
Write-Host "提示: 关闭终端窗口即可停止服务" -ForegroundColor Gray
Write-Host ""

# 暂停，让用户看到消息
Read-Host "按回车键关闭此窗口"

